package com.xinchuang.domain.type;


import org.apache.commons.lang3.StringUtils;

/**
 * @author zkwczx
 */
public enum NoticeMainEnum {

    /**
     * 描述信息
     */
    CREATE_PLAN("0", "试模工单需审批后，在开始试模"),

    START_MOLD_TIME("1", "开始试模时间"),

    END_MOLD_TIME("2", "完成试模时间"),

    TEST_MOLD_REPORT("3", "已填写试模报告"),

    SUBMITTED("4", "已提交"),

    WAIT_APPROVAL("5", "待审批"),

    APPROVAL_DOING("6", "审批中"),

    APPROVAL_ERROR("7", "审批异常，请重新提交审批"),

    APPROVAL_DONE("8", "审批完成");

    private String code;

    private String message;

    NoticeMainEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static String getMessage(String code) {
        if (StringUtils.isBlank(code) || "0".equals(code)) {
            return "待审批";
        }
        for (NoticeMainEnum value : NoticeMainEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getMessage();
            }
        }
        return "待审批";
    }

    public static Integer getMessageName(String code) {
        if (StringUtils.isBlank(code)) {
            return 0;
        }
        switch (code) {
            case "8":
                return 1;
            case "1":
            case "2":
            case "3":
                return 2;
            case "4":
                return 3;
            case "0":
            case "5":
            case "6":
            case "7":
                return 0;
            default:
                return -1;
        }
    }

    public static String getMessageValue(String code) {
        if (StringUtils.isBlank(code)) {
            return "待审批";
        }
        switch (code) {
            case "8":
                return "未试模";
            case "1":
            case "2":
            case "3":
                return "试模中";
            case "4":
                return "试模完成";
            case "0":
                return "待审批";
            case "7":
                return "审批异常，请重新提交审批";
            default:
                return "审批中";
        }
    }

}
